package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 预约记录表
 *
 * @author education-platform
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("appointment")
@JsonIgnoreProperties(value = {"handler"})
public class Appointment {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 家长ID
     */
    @TableField("parent_id")
    private Long parentId;

    /**
     * 教员ID
     */
    @TableField("teacher_id")
    private Long teacherId;

    /**
     * 关联需求ID
     */
    @TableField("demand_id")
    private Long demandId;

    /**
     * 科目
     */
    @TableField("subject")
    private String subject;

    /**
     * 年级
     */
    @TableField("grade")
    private String grade;

    /**
     * 授课方式
     */
    @TableField("teaching_type")
    private String teachingType;

    /**
     * 总课时
     */
    @TableField("total_hours")
    private Integer totalHours;

    /**
     * 时薪
     */
    @TableField("hourly_rate")
    private BigDecimal hourlyRate;

    /**
     * 总金额
     */
    @TableField("total_amount")
    private BigDecimal totalAmount;

    /**
     * 期望时间
     */
    @TableField("preferred_time")
    private String preferredTime;

    /**
     * 上课地址
     */
    @TableField("address")
    private String address;

    /**
     * 预约留言
     */
    @TableField("message")
    private String message;

    /**
     * 状态
     */
    @TableField("status")
    private String status;

    /**
     * 教员回复
     */
    @TableField("teacher_reply")
    private String teacherReply;

    /**
     * 回复时间
     */
    @TableField("replied_at")
    private LocalDateTime repliedAt;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private User parent;
    
    @TableField(exist = false)
    private User teacher;
    
    @TableField(exist = false)
    private UserProfile teacherProfile;
    
    @TableField(exist = false)
    private Demand demand;

    // 枚举定义
    public enum Status {
        PENDING("待处理"),
        ACCEPTED("已接受"),
        REJECTED("已拒绝"),
        PAID("已支付"),
        CANCELLED("已取消");

        private final String description;

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
} 